#include <bits/stdc++.h>
#define mk make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()

using namespace std;
using mset = multiset<int>;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (! isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int maxq = 5e5 + 10, maxv = (1 << 20) + 10, V = 1 << 20;

mset L[maxv], R[maxv];

#define cmin(t) (*t.begin())
#define cmax(t) (*prev(t.end()))
#define ins(s, v) s.insert(v)
#define del(s, v) s.erase(s.find(v))

int mx[maxv << 1], mn[maxv << 1], ans[maxv << 1];
void md(int p, int v, int op) {
	p += V, (op ? mn : mx)[p] = v;
	while (p) {
		p >>= 1;
		mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
		mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
		ans[p] = min({ans[p << 1], ans[p << 1 | 1], mn[p << 1 | 1] - mx[p << 1] + 1});
	}
}

int main() {

	freopen("stone.in", "r", stdin);
	freopen("stone.out", "w", stdout);
	
	int q = read();
	for (int i = 1; i <= V * 2; i ++) 
		mx[i] = -1e9, ans[i] = mn[i] = 1e9;

	while (q --) {
		char op; scanf("%c", &op);
		int l = read(), r = read() - 1;
		
		if (op == 'A') ins(L[l], r), ins(R[r], l);
		else del(L[l], r), del(R[r], l);

		md(r, R[r].empty() ? -1e9 : cmax(R[r]), 0);
		md(l, L[l].empty() ? 1e9 : cmin(L[l]), 1);

		int tl = mx[1], tr = mn[1];
		if (tl <= tr) printf("%d\n", cmin(L[tl]) - cmax(R[tr]) + 1);
		else printf("%d\n", ans[1]);
	}

	return 0;
}